{% load static %}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>大学生就业管理系统</title>
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- SweetAlert2 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', sans-serif;
            background: #f0f2f5;
            min-height: 100vh;
        }

        /* 导航栏样式 */
        .navbar {
            background: #1e3c72;
            padding: 15px 50px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            color: white;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }

        .logo {
            font-size: 24px;
            font-weight: bold;
            color: white;
            text-decoration: none;
        }

        .nav-buttons {
            display: flex;
            gap: 15px;
            align-items: center;
        }

        .btn {
            padding: 8px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
            text-decoration: none;
            transition: all 0.3s ease;
        }

        .btn-login {
            background: transparent;
            border: 1px solid white;
            color: white;
        }

        .btn-login:hover {
            background: rgba(255, 255, 255, 0.1);
        }

        .btn-register {
            background: white;
            color: #1e3c72;
        }

        .btn-register:hover {
            background: #f8f9fa;
            transform: translateY(-1px);
        }

        .user-profile {
            display: flex;
            align-items: center;
            gap: 15px;
            cursor: pointer;
            position: relative;
        }

        .user-avatar {
            width: 35px;
            height: 35px;
            border-radius: 50%;
            background: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #1e3c72;
            font-weight: bold;
            font-size: 16px;
        }

        .user-name {
            color: white;
            font-size: 16px;
            margin-left: 5px;
            font-weight: 500;
        }

        .dropdown-menu {
            position: absolute;
            top: 100%;
            right: 0;
            background: white;
            border-radius: 4px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            margin-top: 10px;
            min-width: 150px;
            display: none;
            z-index: 1000;
        }

        .user-profile:hover .dropdown-menu {
            display: block;
        }

        .dropdown-menu a {
            display: block;
            padding: 10px 15px;
            color: #333;
            text-decoration: none;
            transition: background 0.3s;
        }

        .dropdown-menu a:hover {
            background: #f8f9fa;
        }

        /* 主要内容区域 */
        .main-content {
            max-width: 1200px;
            margin: 40px auto;
            padding: 0 20px;
        }

        .search-section {
            text-align: center;
            margin-bottom: 40px;
            position: relative;
        }

        .search-input {
            width: 500px;
            padding: 12px 20px;
            border: 1px solid #ddd;
            border-radius: 25px;
            font-size: 16px;
            transition: all 0.3s;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
        }

        .search-input:focus {
            outline: none;
            border-color: #1e3c72;
            box-shadow: 0 2px 10px rgba(30, 60, 114, 0.1);
        }

        /* 职位卡片样式 */
        .job-card {
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
            margin-bottom: 20px;
            border: none;
            cursor: pointer;
        }

        .job-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

        .job-card-header {
            background-color: #1e3c72;
            color: white;
            padding: 15px;
            border-top-left-radius: 8px !important;
            border-top-right-radius: 8px !important;
        }

        .job-card-body {
            padding: 20px;
        }

        .job-card-footer {
            background-color: #f8f9fa;
            padding: 15px;
            border-bottom-left-radius: 8px !important;
            border-bottom-right-radius: 8px !important;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .salary-badge {
            background-color: #28a745;
            color: white;
            padding: 5px 10px;
            border-radius: 4px;
            font-weight: bold;
        }

        .apply-btn {
            background-color: #ffc107;
            color: #212529;
            border: none;
            padding: 8px 20px;
            border-radius: 4px;
            font-weight: bold;
            transition: all 0.3s;
        }

        .apply-btn:hover {
            background-color: #e0a800;
            transform: translateY(-2px);
        }

        @media (max-width: 768px) {
            .navbar {
                padding: 15px 20px;
            }

            .search-input {
                width: 100%;
            }
        }
    </style>
</head>
<body>
<nav class="navbar">
    <a href="{% url 'author:student_index' %}" class="logo">大学生就业管理系统</a>
    <div class="nav-buttons">
        {% if user.is_authenticated %}
            <div class="user-profile">
                <div class="user-avatar">
                    <img src="{% static 'image/xiaoqin.png' %}" alt="">
                    {{ user.username|first|upper }}
                </div>
                <span class="user-name">{{ user.username }}</span>
                <div class="dropdown-menu">
                    <a href="{% url 'author:logout' %}" style="color: #dc3545;"><i class="fas fa-sign-out-alt"></i> 退出登录</a>
                </div>
            </div>
        {% else %}
            <a href="{% url 'author:login' %}" class="btn btn-login">登录</a>
            <a href="{% url 'author:register' %}" class="btn btn-register">注册</a>
        {% endif %}
    </div>
</nav>

<div class="container mt-4">
    {% csrf_token %}
    <div class="search-section">
        <form class="me-2" role="search" method="GET" action="{% url 'job_apply:search_job' %}">
            <input type="search" name='keyword' class="form-control" placeholder="搜索公司、职位..." aria-label="Search">
        </form>
    </div>

    <main>
        {% block content %}
            <div class="container">
                <h1 class="mb-4">职位列表</h1>
                <div class="row">
                    {% for job in jobs %}
                        <div class="col-md-6 col-lg-4 mb-4">
                            <div class="card-header job-card-header">
                                <h5 class="card-title mb-1">{{ job.title }}</h5>
                                <div class="d-flex justify-content-between">
                                    <span>{{ job.company }}</span>
                                    <span><i class="fas fa-map-marker-alt"></i> {{ job.location }}</span>
                                </div>
                            </div>
                            <div class="card-body job-card-body">
                                <div class="d-flex justify-content-between align-items-center mb-3">
                                    <span class="salary-badge">{{ job.salary_range }}</span>
                                </div>
                                <h6 class="card-subtitle mb-2 text-muted">职位描述</h6>
                                <p class="card-text">{{ job.description|truncatechars:100 }}</p>
                                <h6 class="card-subtitle mb-2 text-muted">职位要求</h6>
                                <p class="card-text">{{ job.requirements|truncatechars:100 }}</p>
                            </div>
                            <div class="card-footer job-card-footer">
                                <small class="text-muted">发布于: {{ job.created_at|date:'Y-m-d' }}</small>
                                <button type="button"
                                        class="btn btn-primary apply-btn"
                                        data-job-id="{{ job.id }}"
                                        onclick="handleApplyJob({{ job.id }})">
                                    立即申请
                                </button>
                            </div>
                        </div>
                    {% endfor %}
                </div>
            </div>
        {% endblock %}
    </main>
</div>

<!-- Bootstrap 5 JS Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<!-- SweetAlert2 JS -->
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.all.min.js"></script>
<script src="{% static 'js/job_apply.js' %}"></script>
</body>
</html>